package com.ship.dispatch.bean;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ship.common.core.base.ContractBaseBean;
import com.ship.common.core.base.Joinable;
import com.ship.common.core.mapping.Label;
import com.ship.common.core.mapping.SearchItem;
import com.ship.common.core.mapping.TableColumn;
import com.ship.common.core.validate.Add;
import com.ship.common.core.validate.Update;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;

import java.io.Serializable;

/**
 * 资源合同-主合同
 * @author 31463
 */
@TableName("con_resource_main")
@Data
public class ConResourceMain extends ContractBaseBean implements Joinable {


    private static final long serialVersionUID = -2668913270284617442L;
    @NotNull(message = "模板主键不能为空", groups = {Update.class})
    private Long id;

    /**
     *合同编号
     */
    @Label(value="合同编号")
    @SearchItem
    @TableColumn
    private String contractNumber;

    /**
     *合同名称
     */
    @Label(value="合同名称")
    @SearchItem
    @TableColumn
    private String contractName;

    /**
     *贸易类型(长协、中期、现货)
     */
    @Label(value="贸易类型",enumContent = "贸易类型",multiSelect=true)
    @SearchItem
    @TableColumn
    @NotNull(message = "贸易类型不能为空", groups = {Add.class})
    private Integer tradeType;

    /**
     *贸易主体(国贸、新贸)
     */
    @Label(value="贸易主体",enumContent = "贸易主体",multiSelect = true)
    @SearchItem
    @TableColumn
    @NotNull(message = "贸易主体不能为空", groups = {Add.class})
    private Integer tradeBody;

    @TableField(exist = false)
    private String tradeBodyListForSearch;

    /**
     *签订日期
     */
    @Label(value="签订日期")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @SearchItem
    @TableColumn
    @NotNull(message = "签订日期不能为空", groups = {Add.class})
    private Date signingDate;


    /**
     *合作方-海油
     */
    @Label(value="合作方-海油")
    @SearchItem
    @TableColumn
    @NotBlank(message = "合作方-海油不能为空", groups = {Update.class,Add.class})
    @Size(max = 255, message = "合作方-海油长度不能超过255", groups = {Update.class, Add.class})
    private String partnerA;

    /**
     *合作方
     */
    @Label(value="合作方")
    @SearchItem
    @TableColumn
    @NotBlank(message = "合作方不能为空", groups = {Update.class,Add.class})
    @Size(max = 255, message = "合作方长度不能超过255", groups = {Update.class, Add.class})
    private String partnerB;

    /**
     *删除申请
     */
    @Label(value="删除申请",boolContent = true)
    private Boolean delApply;

    /**
     *合同状态
     */
    @Label(value="合同状态",enumContent = "合同状态")
    @TableColumn
    private Integer status;

    /**
     *优秀案例
     */
    @Label(value="优秀案例",enumContent = "是否是优秀案例")
    private Integer excellent;

    /**
     * 附件地址
     */
    @TableField(exist = false)
    private String filePath;

    /**
     * 合同上传时间
     */
    @Label(value="合同上传时间")
    @SearchItem
    @TableColumn
    @TableField(fill = FieldFill.INSERT)
    private Date createDate;

    /**
     * 创建者
     */
    @Label(value="创建者")
    @SearchItem
    @TableColumn
    @TableField(fill = FieldFill.INSERT)
    private String createBy;

    @Override
    public String getLabel() {
        return this.getContractName();
    }

    @Override
    public String getValue() {
        return this.getId().toString();
    }
}
